package com.googlecode.monitoring.model;

import com.googlecode.monitoring.service.CheckedStateOfItem;
import com.googlecode.monitoring.service.EmailSentStateOfItem;
import com.googlecode.monitoring.service.NewStateOfItem;

/**
 * Date: Jun 7, 2010
 * Time: 5:38:09 PM
 */
public enum StateName {
	CHECKED("checked", CheckedStateOfItem.class),
	EMAIL_SENT("email_sent", EmailSentStateOfItem.class),
	NEW("new", NewStateOfItem.class);

	private String name;
    private Class className;

	StateName(String name,Class className) {
		this.name = name;
        this.className = className;
	}

    public Class getClassName() {
        return className;
    }

    public String getName() {
		return name;
	}

	public static StateName buildFromString(String str) {
		for (StateName state : com.googlecode.monitoring.model.StateName.values()) {
			if (str.equalsIgnoreCase(state.getName())) {
				return state;
			}
		}
		throw new IllegalArgumentException("Invalid State value");
	}

	@Override
	public String toString() {
		final StringBuilder sb = new StringBuilder();
		sb.append("State");
		sb.append("{name='").append(name).append('\'');
		sb.append('}');
		return sb.toString();
	}

}
